# 在goland环境下对链程序进行编译
FROM golang:1.16.9-alpine as builder
# 换源和安装依赖
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk add --no-cache make gcc musl-dev linux-headers git
# 将当前目录添加到容器
ADD . /aqchain
# 执行make编译链程序
RUN cd /aqchain  && make aqchain

# 使用alpine环境作为运行
FROM alpine:latest
# 换源和安装依赖
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk add --no-cache ca-certificates bash bash-doc bash-completion
# 将编译好的可执行文件复制到bin目录下
COPY --from=builder aqchain/build/bin/aqchain /usr/local/bin/
COPY /wait-for-it.sh /usr/local/bin/

ADD ./resource /aqchain/resource